********************************************************************************
*
**#	Fig 3: Distribution of Sentence Length by DV court vs General court
*
********************************************************************************

use "${DATA}/data_DV.dta", clear

preserve

	/* keep DV cases */
	
	keep if dv_case == 1 
	
	/* Calculate means */
	
	sum   jail_time_case if dv_judge == 1 & guilty_case==1   
	
	local jld_avg: di %2.1f r(mean) 
	
	sum   jail_time_case if dv_judge == 0 & guilty_case==1  
	
	local jlg_avg: di %2.1f r(mean) 
	
	/* graph options */ 
	
	local label_opts "lcolor(black) lwidth(medthick) msize(small) mcolor(black)" 

	# d ;
	
	graph twoway  
		(kdensity jail_time_case if dv_judge == 1 & guilty_case==1,`label_opts')
		(kdensity jail_time_case if dv_judge == 0 & guilty_case ==1,`label_opts' lpattern(dash) lcolor(black*0.8)) , 
		ytitle("") 
		xtitle("Sentence Length (in days)", margin(0 0 0 2.5))	
		xlabel(0 30 60 90 120 180 270 360,	labsize(medsmall))
		ylabel(,angle(0) nogrid labsize(medsmall))	
		note(
			"Kernel Density Estimates (Conditional on Conviction)"
			"DV Courts avg. = `jld_avg' and General Courts avg. = `jlg_avg'.", 
			size(small) margin(l-8 t+2 b-2))
		legend(
			on size(small) pos(2) ring(0) order(1 2) 
			label(1 DV Court) label(2 General Court) col(1) region(style(none)))
		xsize(16) ysize(20) ;

	# d cr 
	
	 graph save "${OUTPUT}/fig3.gph", replace 
	
restore
